package com.hand.todo.api.controller.v1;

/*
 *@ClassName MessageController
 *@Description TODO
 *@Author Administrator
 *@Date 2021/7/31 12:05
 *@Version 1.0
 */


import io.choerodon.core.iam.ResourceLevel;
import io.choerodon.swagger.annotation.Permission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.hzero.boot.message.MessageClient;
import org.hzero.boot.message.entity.Receiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;

@RestController("handMessageController.v1")
@RequestMapping("/hptl/v1")
public class MessageController {
    @Autowired
    private MessageClient messageClient;

    @ApiOperation("工作流状态变化邮件提醒")
    @Permission(level = ResourceLevel.SITE)
    @GetMapping("/message")
    public String message(@RequestParam("str") String str) {
        //租户id，
        Long tenantId = 0L;
        //邮箱编码
        String serviceCode = "DEMO";
        //邮件模板编码
        String MessageTemplateCode = "NOTICE";
        //设置收件人
        ArrayList<Receiver> receiverList = new ArrayList<>();
        Receiver receiver = new Receiver();
        receiver.setEmail("weiye_lee@163.com");
        receiverList.add(receiver);
        //邮件参数
        HashMap<String, String> args = new HashMap<>();
        args.put("status", str);
        messageClient.sendEmail(tenantId, serviceCode, MessageTemplateCode, receiverList, args, null);
        return "处理完成";
    }

}
